<?php
/**
 * @Notes:【】
 * @User: zwc
 * @Date: 2022-05-14 0:20
 */

namespace App\Service\Chat;

use App\Dao\Chat\ChatRecordsDao;
use App\Dao\Chat\ChatSessionDao;
use App\Service\BaseService;
use App\WsService\Message\ChatService;
use Hyperf\Di\Annotation\Inject;

class ChatRecordsService extends BaseService
{

    /**
     * @Inject()
     * @var ChatRecordsDao
     */
    protected $chatRecordsDao;

    public function lists($userId, $receiver_id)
    {
        return $this->chatRecordsDao->getRecords($userId, $receiver_id);
    }

    /**
     * @Notes:【发送一次剩余消息】
     * @User: zwc
     * @Date: 2022/6/17 16:50
     */
    public function read(\App\Tool\Collect $params)
    {
        App(ChatService::class)->SendUnReadNum($params->get('user_id'));
        return $this->chatRecordsDao->DaoWhere($params->only(['user_id', 'receiver_id'])->toArray())->update([
            'is_read' => 1,
        ]);
    }
}